home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / disk.h < prev    next >
C/C++ Source or Header  |  1990-10-10  |  5KB  |  132 lines

  1. /*
  2.  * disk.h --
  3.  *
  4.  *    Definitions for utilities that examine an OFS filesystem through
  5.  *    a raw disk interface.
  6.  *
  7.  * Copyright 1990 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /sprite/src/lib/c/disk/RCS/disk.h,v 1.2 90/06/26 21:29:08 jhh Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _DISK
  20. #define _DISK
  21.  
  22. #include <kernel/fs.h>
  23. #include <kernel/dev.h>
  24. #include <kernel/fsdm.h>
  25. #include <kernel/ofs.h>
  26. #include <kernel/devDiskLabel.h>
  27.  
  28. /*
  29.  * These should be here.  They should be in some machine dependent header
  30.  * file.  But for now ...
  31.  */
  32. #define BITS_PER_BYTE           8
  33. #define BITS_PER_INT            32
  34.  
  35. /*
  36.  * DISK_SECTORS_PER_BLOCK    Number of disk sectors per file system block.
  37.  * DISK_KBYTES_PER_BLOCK    Number of kbyte chunks per file system block.
  38.  */
  39. #define DISK_SECTORS_PER_BLOCK       (FS_BLOCK_SIZE / DEV_BYTES_PER_SECTOR)
  40. #define DISK_KBYTES_PER_BLOCK        (FS_BLOCK_SIZE / 1024)
  41.  
  42. /*
  43.  * Maximum number of partitions on a disk.
  44.  */
  45. #define DISK_MAX_PARTS 8
  46.  
  47. /*
  48.  * Maximum length of an ascii label inside a disk label.
  49.  */
  50. #define DISK_MAX_ASCII_LABEL 256
  51.  
  52. /*
  53.  * We understand two types of native disk labels: Sun labels and DEC labels.
  54.  */
  55.  
  56. typedef int Disk_NativeLabelType;
  57.  
  58. #define DISK_NO_LABEL  ((Disk_NativeLabelType) 0)
  59. #define DISK_SUN_LABEL ((Disk_NativeLabelType) 1)
  60. #define DISK_DEC_LABEL ((Disk_NativeLabelType) 2)
  61.  
  62. /*
  63.  * Information about a disk partition.
  64.  */
  65. typedef struct Disk_Partition {
  66.     int        firstCylinder;        /* First cylinder in partition. */
  67.     int        numCylinders;        /* Number of cylinders in partition.*/
  68. } Disk_Partition;
  69.  
  70. /*
  71.  * This is a canonical disk label.  The use of this structure allows
  72.  * programs to read and write disk labels without worrying about
  73.  * the format of the machine-specific disk label.  Fields labelled (RO)
  74.  * are read-only.  They should not be modified by a user program.
  75.  * Fields labelled (+) can be modified by user programs, but the results
  76.  * may not be what is desired.  These fields reflect the location and size
  77.  * of other data structures on the disk.  Simply changing them in the
  78.  * label will not suffice.  The data structures will have to be moved also.
  79.  * For some types of machines it is not possible to change these fields
  80.  * because their location is hard-wired into the prom.  Refer to the prom
  81.  * documentation and kernel source code.  The bottom line is you don't
  82.  * want to change the (+) fields unless you really know what you're doing.
  83.  */
  84. typedef struct Disk_Label {
  85.     int    numHeads;        /* Number of heads */
  86.     int    numSectors;        /* Number of sectors per track */
  87.     int numCylinders;        /* Number of cylinders on the disk. */
  88.     int numAltCylinders;    /* Number of alternate cylinders. */
  89.     char asciiLabel[DISK_MAX_ASCII_LABEL];    /* Ascii label. */
  90.     Disk_Partition partitions[DISK_MAX_PARTS]; /* Partition map */
  91.     Disk_NativeLabelType labelType; /* Type of native disk label */
  92.     char *labelPtr;        /* Pointer to native disk label. */
  93.     int    bootSector;        /* (+) Starting sector of boot program */
  94.     int    numBootSectors;     /* (+) Number of boot sectors. */
  95.     int    summarySector;        /* (+) Start of summary information. */
  96.     int    numSummarySectors;     /* (+) Number of sectors in summary info. */
  97.     int domainSector;        /* (+) Sector where domain header starts. */
  98.     int numDomainSectors;    /* (+) Number of sectors in domain header. */
  99.     int numPartitions;        /* (RO) Number of partitions on disk. */
  100.     int asciiLabelLen;        /* (RO) Length of ascii label. */
  101.     int labelSector;        /* (RO) Location of native disk label. */
  102. } Disk_Label;
  103.  
  104. /*
  105.  * Forward Declarations.
  106.  */
  107. Disk_Label        *Disk_ReadLabel();
  108. int            Disk_WriteLabel();
  109. int            Disk_EraseLabel();
  110. Disk_Label        *Disk_NewLabel();
  111. Dec_DiskLabel        *Disk_ReadDecLabel();
  112. Sun_DiskLabel        *Disk_ReadSunLabel();
  113. Fsdm_DiskHeader        *Disk_ReadDiskHeader();
  114. Ofs_SummaryInfo        *Disk_ReadSummaryInfo();
  115. int            Disk_WriteSummaryInfo();
  116. Ofs_DomainHeader    *Disk_ReadDomainHeader();
  117. int            Disk_WriteDomainHeader();
  118. void            Disk_PrintDomainHeader();
  119. void            Disk_PrintSummaryInfo();
  120. int            Disk_BlockWrite();
  121. int            Disk_SectorWrite();
  122. int            Disk_BlockRead();
  123. int            Disk_SectorRead();
  124. int            Disk_BadBlockRead();
  125. void            Disk_PrintLabel();
  126. char            *Disk_GetLabelTypeName();
  127. void            Disk_PrintFileDescBitmap();
  128. void            Disk_PrintDataBlockBitmap();
  129. void            Disk_PrintDirEntry();
  130.  
  131. #endif DISK
  132.